#include <stdio.h>

int main() {
    int num = 0;
    printf("请输入要查找的数据:>");
    scanf("%d", &num);
    int arr[] = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11,};
    int sz = sizeof(arr) / sizeof(arr[0]);
    int left = 0;//左下标
    int right = (sz - 1);//右下标
    int i = 1;
    for (i = 1; right >= left; i++) {
        int mid = (left + right) / 2;
        if (arr[mid] == num) {
            printf("查找次数:> %d\n查找结果:> %d\n", i, arr[mid]);
            break;
        } else
        if (arr[mid] < num) {
            left = mid + 1;
        } else
        if (arr[mid] > num) {
            right = mid - 1;
        }
    }
    if (left > right) {
        printf("没有找到\n");
    }
    return 0;
}